const express = require('express')
const router = express.Router()
const UserModel = require('../modles/user')
// router.get("/:name", function (req, res) {
//     res.render('user', {
//         name: req.params.name
//     })
// });
router.get('/list', (req, res) => {
    res.render('user', {
        list: [],
        title: '用户列表', layout: 'layout'
    });
});
router.post('/list', (req, res, next) => {
    let param = {
        page: Number(req.fields.page),
        pageSize: Number(req.fields.pageSize)
    }
    Promise.all([
        UserModel.findUserList(param),
        UserModel.findUserCount()
    ]).then(function (result) {
        let param={
            data:result[0],
            count:result[1]
        }
       res.send(param);
    })
        .catch(next)


});
module.exports = router